<!-- quirks -->
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8"/>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
	<meta name="renderer" content="webkit"/>
	<title>Set</title>
	<link href="../ting-quirks.css" rel="stylesheet"/>
	<!--[if lt IE 9]><script src="../dist/sky-compat.js"></script><![endif]-->
	<!--[if gte IE 9]><!--><script src="../dist/sky-modern.js"></script><!--><![endif]-->
	<script src="../demo.js"></script>
</head>
<body>
<div class="container-fluid">
	<h3 id="Set">Set</h3>
	<p>无序集合</p>
	<table class="table table-bordered table-condensed table-striped">
		<thead>
		<tr class="primary">
			<th>方法</th><th>返回</th><th>描述</th>
		</tr>
		</thead>
		<tbody class="table-hover">
		<tr>
			<td>add</td><td></td><td>添加元素</td>
		</tr>
		<tr>
			<td>has</td><td>返回布尔值</td><td>判断是否存在某个元素</td>
		</tr>
		<tr>
			<td>delete</td><td></td><td>删除某个元素</td>
		</tr>
		<tr>
			<td>clear</td><td></td><td>清除内部所有元素</td>
		</tr>
		<tr>
			<td>forEach</td><td></td><td>对数组的每个元素执行一次提供的函数(回调函数)</td>
		</tr>
		</tbody> 
	</table>
	<pre class="code">//基本用法
var s = new Set();
s.add("Thomas Jefferson");
s.add(1776);
s.add("founding father");

s.forEach(function (item) {
	alert(item);
});</pre>
	<div class="btn-toolbar">
		<a class="btn btn-primary" href="javascript:void 0;" onclick="run(this)">运行</a>
	</div>
	<pre class="code">//删除
var s = new Set([1,2,3,3]);
s['delete'](3);
alert(s.size);//2
s.clear();
alert(s.size);//0</pre>
	<div class="btn-toolbar">
		<a class="btn btn-primary" href="javascript:void 0;" onclick="run(this)">运行</a>
	</div>
	<pre class="code">//特殊类型
var s = new Set([1,"1",new String("1"),new Number(1),NaN,0,false,true,null,undefined]);
alert(s.size);//10

s.forEach(function (item) {
	alert(item);
});</pre>
	<div class="btn-toolbar">
		<a class="btn btn-primary" href="javascript:void 0;" onclick="run(this)">运行</a>
	</div>
	<pre class="code">//转数组
var s=new Set([1,2,3,3]);
alert(Array.from(s).join(","));</pre>
	<div class="btn-toolbar">
		<a class="btn btn-primary" href="javascript:void 0;" onclick="run(this)">运行</a>
	</div>
</div>
</body>
</html>